
@include('../header')

<div class="body_bg">
	<div class="container">
		<!-- 主列表 -->
		<ul class="ul_nav left">
			<li >
				<a class="li_01 " href="/invitation/1/edit">编辑喜帖</a>
			</li>
			<li >
				<a class="li_02" href="/invitation/list">查看喜帖</a>
			</li>
			<li class="active">
				<a class="li_04 active" href="/invitation/bless">祝福留言</a>
			</li>
			<li >
				<a class="li_05" href="/invitation/attend">出席名单</a>
			</li>
		</ul>
		<div class="left container_box">
			<div class="tit">
				<p>
					<a class="active" id="three2" href="">祝福留言</a>
				</p>
			</div>
			<div id="bless_list" class="table">
				
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	//获取全部喜帖
	window.onload = function(){
        //祝福留言
        $.ajax({
            type: "GET",
            url:'/api/v1/bless',
            success: function(data) {
              if (!data.error) {
              	var blessing= data.result;
              	var invitation = new Array();
              	for (var i = blessing.length - 1; i >= 0; i--) {
              		if (!$.inArray(blessing[i].invitation_id, invitation)) {
              			var blehtml  = '<tr>\
	                          <td>'+blessing[i].name+'</td>\
	                          <td>'+blessing[i].phone+'</td>\
	                          <td>'+blessing[i].content+'</td>\
	                          <td>'+blessing[i].create_at+'</td>\
	                        </tr>';
	                  	$("#bless_"+blessing[i].invitation_id).append(blehtml);
              		}else{
              			invitation.push(blessing[i].invitation_id);
          			    var bletit = '<div class="bless_box">\
                            <div class="bless_tit">\
                              <p class="left">新郎：<span class="man_name">'+blessing[i].boy_name+'</span></p>\
                              <p class="right">新娘：<span class="women_name">'+blessing[i].girl_name+'</span></p>\
                            </div>\
                            <table id="bless_'+blessing[i].invitation_id+'">\
                              <tr>\
                                <th>姓名</th>\
                                <th>电话</th>\
                                <th>祝福留言</th>\
                                <th>时间</th>\
                              </tr>\
                            </table>\
                          </div>';
                 		$('#bless_list').append(bletit);
                 		var blehtml  = '<tr>\
	                          <td>'+blessing[i].name+'</td>\
	                          <td>'+blessing[i].phone+'</td>\
	                          <td>'+blessing[i].content+'</td>\
	                          <td>'+blessing[i].create_at+'</td>\
	                        </tr>';
	                  	$("#bless_"+blessing[i].invitation_id).append(blehtml);
              		};
              		
              	};
              };
            }
        });
	};
</script>
@include('../footer')